package com.zjjk.transfer.app;

import com.zjjk.transfer.source.entity.SourcePosPaymentRecords;
import com.zjjk.transfer.source.service.SourcePosPaymentRecordsService;
import com.zjjk.transfer.target.entity.TargetPosPaymentRecords;
import com.zjjk.transfer.target.service.TargetPosPaymentRecordsService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

@Component
public class PosPaymentRecordsTransfer extends BaseTransfer<SourcePosPaymentRecords, TargetPosPaymentRecords, SourcePosPaymentRecordsService, TargetPosPaymentRecordsService> {

    @Override
    protected TargetPosPaymentRecords convert(SourcePosPaymentRecords source) {
        if (source.getPayType().equals(301)){
            return null;
        }
        TargetPosPaymentRecords target = new TargetPosPaymentRecords();

        BeanUtils.copyProperties(source,target);
        if (source.getPayStatus() == 3){
            target.setPayStatus(0);
        }
        target.setId(Long.valueOf(source.getId()));
        target.setPayee(Long.valueOf(source.getPayee()));
        if (null!=source.getPayer()){
            target.setPayer(Long.valueOf(source.getPayer()));
        }
        target.setDeleted(0);
        return target;
    }
}
